package com.qf.config;

import com.team5101.constant.RabbitMQ;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {
    @Bean
    public TopicExchange getTopic(){
        return new TopicExchange(RabbitMQ.PRODUCT_ADD_EXCHANGE);
    }

    @Bean
    public Queue getQueue(){
        return new Queue(RabbitMQ.PRODUCT_ADD_SEARCH_QUEUE);
    }

    @Bean
    public Binding getBinding(TopicExchange topicExchange,Queue queue){
     return BindingBuilder.bind(queue).to(topicExchange).with("product.add");
    }
}
